/*================================================================
*   Copyright (C) 2020 belonging to YangZhengQing. All rights reserved.
*   
*   文件名称：sqlite3_connect.c
*   创 建 者：YangZhengQing
*   创建日期：2020年03月18日
*   描    述：
*
*================================================================*/


//#include "sqlite3_connect.h"

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <sqlite3.h>


#define database_name "test.db"

int main(int argc, char **argv)
{

	sqlite3				*db;//定义数据库操作句柄

	int					rv = -1;//函数返回值


	rv = sqlite3_open(database_name,&db);//打开数据库
	printf("rv=%d\n",rv);
	if(rv < 0)
	{
		printf("Can't create or open database!:%s\n",sqlite3_errmsg(db));
		exit(0);
	}

	else
	{
		printf("Creating or opening database successfully!\n");
	}

	rv = sqlite3_close(db);//关闭数据库
	printf("rv=%d\n",rv);
	if(rv < 0)
	{
		 printf("Closing database failly!:%s\n",sqlite3_errmsg(db));
		 exit(0);
	}
	printf("Closing database successfully!\n");
}
